package com.binecy.controller;

import com.binecy.bean.Order;
import com.binecy.service.OrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {
    private static final Logger logger = LoggerFactory.getLogger(OrderController.class);

    @Autowired
    private OrderService service;

    @GetMapping("/user/{userId}")
    public Mono<Order> listOrder(@PathVariable long userId) {
        logger.info("listOrder start");
        Mono<Order> orderMono =  service.getOrder(userId);
        logger.info("listOrder end");
        return orderMono;
    }


    @GetMapping("/test1/{id}")
    public Mono<Order> id(@PathVariable long id) {
        logger.info("listOrder start");
        Mono<Order> orderMono =  service.getById();
        logger.info("listOrder end");
        return orderMono;
    }

    @GetMapping("/test2/{id}")
    public Order id2(@PathVariable long id) {
        logger.info("listOrder2 start");
        Order orderMono =  service.getById2();
        logger.info("listOrder2 end");
        return orderMono;
    }
}
